home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
lockpr.arc
/
LOCKONE.C
< prev
next >
Wrap
Text File
|
1988-09-01
|
5KB
|
185 lines
/* ««< Include Files >»» */
#include "xql.h"
#include "stdio.h"
/* ««< Function Definitions >»» */
void init_string (int string_length, char *string);
/* ««< Symbolic Constants >»» */
#define CLIENT_NO long
#define COMPANY_NAME_LENGTH 76
#define LAST_NAME_LENGTH 21
#define FIRST_NAME_LENGTH 23
#define MIDDLE_INIT_LENGTH 3
#define ADDRESS_LENGTH 41
#define ZIPCODE_LENGTH 11
#define LAST_NAME_LENGTH 21
#define CLIENT_ALPHA_LENGTH 6
#define CASE_NAME_LENGTH 41
#define PHONE_NUM_LENGTH 14
/* ««< Enumerated Data Types >»» */
typedef enum { FETCH_CURRENT, FETCH_FIRST, FETCH_NEXT, FETCH_PREVIOUS, FETCH_LAST, RELEASE = 7, NOWAIT_IMPLICIT = 1024, NOWAIT_EXPLICIT = 4096 } XQL_REC_FETCH_TYPE;
typedef enum { CHARACTER, INTEGER, FLOAT, DATE, TIME, DECIMAL, MONEY, LOGICAL, NUMERIC, BFLOAT, LSTRING, ZSTRING, NOTE, LVAR } XQL_DATA_TYPES;
typedef enum { FALSE, TRUE } BOOLEAN;
/* ««< Structures >»» */
typedef struct {
char company_name[COMPANY_NAME_LENGTH],
last_name[LAST_NAME_LENGTH],
first_name[FIRST_NAME_LENGTH],
middle_initial[MIDDLE_INIT_LENGTH],
addr_one[ADDRESS_LENGTH],
addr_two[ADDRESS_LENGTH],
addr_three[ADDRESS_LENGTH],
city[ADDRESS_LENGTH],
state[ADDRESS_LENGTH];
char zipcode[ZIPCODE_LENGTH];
int primary_atty;
char client_alpha[CLIENT_ALPHA_LENGTH];
CLIENT_NO client_number;
char phone_num[PHONE_NUM_LENGTH];
} CLIENT_RECORD;
/* ««< Global Variables >»» */
int SQLCODE;
char xql_command[] = {"Select * from clients"};
main ( )
{
CLIENT_RECORD client_record;
char xql_fetchbuf[800];
int xql_status,
xql_cursor,
xql_buflen,
xql_fetch_flag,
xql_fetch_spacing,
xql_command_strlen,
loop_count,
lcv;
long xql_fetch_count;
/* Login to XQL */
xql_status = XQLLogin ("", "", "", "", "", 0);
/* Request Cursor */
xql_status = XQLCursor (&xql_cursor);
if (xql_status) {
printf (" Error : %d XQL Cursor\n\n", xql_status);
}
/* Get String Lengh */
xql_command_strlen = strlen (xql_command);
/* Compile XQL Command */
xql_status = XQLCompile (xql_cursor, &xql_command_strlen, xql_command);
if (xql_status) {
printf (" Error : %d XQL Compile\n\n", xql_status);
}
/* Init Variables */
xql_buflen = 800;
xql_fetch_count = 1;
xql_fetch_flag = 2;
xql_fetch_spacing = 1;
init_string (800, xql_fetchbuf);
/* Fetch First Record */
xql_status = XQLFetch (xql_cursor, FETCH_FIRST + NOWAIT_EXPLICIT, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
if (xql_status) {
printf (" Error : %d XQL Fetch\n\n", xql_status);
XQLLogout ( );
exit ( );
}
else {
printf ("Fetched Record No : 1\n");
}
/* Release Record */
xql_status = XQLFetch (xql_cursor, FETCH_CURRENT + RELEASE, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
if (xql_status) {
printf (" Error : %d XQL Release\n\n", xql_status);
XQLLogout ( );
exit ( );
}
else {
printf ("Released Record No : 1\n\n" );
}
/* Init Loop Count & Loop Control variable */
loop_count = 1;
lcv = TRUE;
while (lcv) {
/* Init Variables */
xql_buflen = 800;
xql_fetch_count = 1;
xql_fetch_flag = 2;
xql_fetch_spacing = 1;
printf ("Loop Number : %d\n", loop_count);
/* Fetch Next Record */
xql_status = XQLFetch (xql_cursor, FETCH_NEXT + NOWAIT_EXPLICIT, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
if (xql_status) {
printf (" Error : %d XQL Fetch\n\n", xql_status);
lcv = FALSE;
}
else {
printf ("Fetched Record No : %d\n", loop_count);
}
/* Release Record */
xql_status = XQLFetch (xql_cursor, FETCH_CURRENT + RELEASE, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
if (xql_status) {
printf (" Error : %d XQL Release\n\n", xql_status);
lcv = FALSE;
}
else {
printf ("Released Record No : %d\n\n\n", loop_count);
}
/* Increment Loop Count */
loop_count++;
} /* end while */
} /* END MAIN */
void init_string (int string_length, char *string)
{
int index;
for (index = 0; index < string_length; index++)
string[index] = NULL;
}